//
//  SocietatiCarteVerdeViewController.m
//  RCA24
//
//  Created by Bogdan Boca on 2/19/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "SocietatiCarteVerdeViewController.h"

@implementation SocietatiCarteVerdeViewController

@synthesize companiesTableView;
@synthesize backButton;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    UIImage * backgroundPattern = [UIImage imageNamed:@"bg-app.png"];
    [self.view setBackgroundColor:[UIColor colorWithPatternImage:backgroundPattern]];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)dealloc
{
    [super dealloc];
    
    [companiesTableView release];
    [backButton release];
}

#pragma mark Table

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 7;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ static NSString *CellIdentifier = @"Cell";
    
    SocietatiTableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        
        NSArray* views = [[NSBundle mainBundle] loadNibNamed:@"SocietatiTableCell" owner:nil options:nil];
        
        for (UIView *view in views) {
            if([view isKindOfClass:[UITableViewCell class]])
            {
                cell = (SocietatiTableCell*)view;
            }
        }
    }
    
    
    if(indexPath.row == 0)
    {
        cell.companiesLabel.text = @"Astra";
        [cell.okImage setImage:[UIImage imageNamed:@"okay.png"]];
    }
    else if(indexPath.row == 1)
    {
        cell.companiesLabel.text = @"BCR";
    }
    else if(indexPath.row == 2)
    {
        cell.companiesLabel.text = @"Generali";
        [cell.okImage setImage:[UIImage imageNamed:@"okay.png"]];
    }
    else if(indexPath.row == 3)
    {
        cell.companiesLabel.text = @"Carpatica";
        [cell.okImage setImage:[UIImage imageNamed:@"okay.png"]];
    }
    else if(indexPath.row == 4)
    {
        cell.companiesLabel.text = @"Asirom";
    }
    else if(indexPath.row == 5)
    {
        cell.companiesLabel.text = @"Allianz - Tiriac";
        [cell.okImage setImage:[UIImage imageNamed:@"okay.png"]];
    }
    else if(indexPath.row == 6)
    {
        cell.companiesLabel.text = @"Ardaf";
        [cell.okImage setImage:[UIImage imageNamed:@"okay.png"]];
    }    
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];

}

- (IBAction)buttonPressed:(id)sender
{
    if(sender == backButton)
    {
        [self.navigationController popViewControllerAnimated:true]; 
    }
}


@end


